<?php
/*=============================================================================
|| ##################################################################
||	phpFoX Konsort
|| ##################################################################
||
||	Copyright		: (C) 2005-2007 PHPFOX Limited a Reality Fox Creation
||	Contact			: info@phpfox.com
||
||	- phpFoX and all of its source code and files are protected by Copyright Laws.
||
||	- The license for phpFoX permits you to install this software on a single domain (.com, .org, .net, etc.).
||
||	- You may also not remove this copyright screen which shows the copyright information and credits for phpFoX (RealityFOX Creations).
||
||	- phpFoX Konsort is NOT a FREE software - http://www.phpfox.com/license/
||
|| ##################################################################
=============================================================================*/

/* $File: ./include/modules/Music/classes/PhpFox_ComponentActualProfileMusic.class.php, $Author:  $ */



/** Component for browsing musicians
 *
 * @version $Id: PhpFox_ComponentActualProfileMusic.class.php 392 2008-03-04 19:54:27Z phpfoxsv $
 * @package module.music
 */
class PhpFox_Mod_Music_ComponentActualProfileMusic extends BaseComponent
{
    function process()
    {
        $oAccountService = &App::getModuleService('Account', 'Account');
        /* @var $oAccountService PhpFox_Mod_Account_ServiceAccount */
        $oSecurityService = &App::getModuleService('Account', 'Security');
        /* @var $oSecurityService PhpFox_Mod_Account_ServiceSecurity */
        // $oSongItem = &$this->_oModule->getItem('Song');
        /* @var $oSongItem PhpFox_Mod_Music_ItemSong */
        $oReq = &App::getRequest();

        $oTpl = &$this->_oModule->getTemplate();

    	if (!$oSecurityService->checkAccess('music', 'public', false))
        {
            return '';
        }
        if (!$oSecurityService->checkPerm('music', array('read_only', 'full'), false))
        {
            return '';
        }
        $sUserName = $oReq->get('name');
        if (!$sUserName)
        {
            return '';
        }

        $iTotalSongs = $this->oDatabase->getField("
        	SELECT COUNT(*) 
        	FROM ". App::getT('music_song') ." AS s
        		JOIN " . App::getT('music_album') . " AS a
        			ON s.album_id = a.album_id
        	WHERE s.user_id = '". $this->_aParams['userId'] ."' AND s.song_is_approved = '1'
        ");

		if ( !$iTotalSongs )
		{
			return '';
		}

        $oTpl->assign(array(
            'aSong' => $this->getParam('userId'),
            'iTotalSongs' => $iTotalSongs
        ));

        return $oTpl->fetch('ActualAccountMusic.html');
    }
}
?>